<?php
       namespace App\Http\Controllers\home;
       use App\Http\Controllers\Controller;
       use Illuminate\Support\Facades\Input;
       use Session;
       use DB;
       class GoodsController extends Controller{
            public function goods($g_id){
            	$u_id = Session::get('u_id');
            	if($u_id){
            		$time = time('Y-m-d');
					$new_time = time();
					$shi = DB::table('mo_footpint')->where(array('g_id'=>$g_id,'u_id'=>$u_id))->first();
					if($shi){
						DB::table('mo_footpint')->where(array('g_id'=>$shi->f_id))->update([
						    'foot_time' => $new_time,
						]);
					}else{
						DB::table('mo_footpint')->insert([
						    'g_id' => $g_id,
						    'foot_time' =>$time,
						    'u_id' => $u_id,
				    	]);
					}
				    $data = DB::table('mo_goods')->where(array('g_id'=>$g_id))->first();
				    $shouc = DB::table('mo_collect')->where(array('g_id'=>$g_id,'u_id'=>$u_id))->first();
	      			return view('home.goods.goods',array('data'=>$data,'shouc'=>$shouc));
	            }else{
	            	$data = DB::table('mo_goods')->where(array('g_id'=>$g_id))->first();
	            	$shouc = array();
            		return view('home.goods.goods',array('data'=>$data,'shouc'=>$shouc));
       			}
            }
        }
?>

